package dao;

import java.util.LinkedList;
import java.util.List;

import relations.Associate;
import relations.belongsTo;
import relations.contains;
import relations.containsas;
import entities.Media_Company;
import entities.Product;
import entities.album;
import entities.order;
import entities.User;

public class containsasDAO {

	private static final containsasDAO instance = new containsasDAO();
	//private List<Product> containsProduct;
	//private List<order> containsOrder;
	private List<containsas> containsasList;
	
	private containsasDAO(){
		//containsProduct = new LinkedList<Product>();
		//containsOrder = new LinkedList<order>();
		containsasList = new LinkedList<containsas>();
		contains cus = null;
		
		//cus = Associate.newInstance("jaime", "Jaime", "Vazquez", "ja@j.com", 1L, "test", "kl", "1", "00778", "PR", "Gurabo", "USA");
		//belongsTos.add(cus);
		//cus = belongsTo.newInstance("jaime1", "Jaime", "Vazquez", "ja@j.com", 2L, "test", "kl", "1", "00778", "PR", "Gurabo", "USA");
		//belongsTos.add(cus);
	}
	
	public static containsasDAO getInstance() {
		return instance;
	}

	public synchronized containsas findContainsas(Long albumPID, Long songPID, String sample) {
		containsas result = null;
		
		for (containsas s : containsasList){
			if (s.getAlbumID().equals(albumPID) && s.getSongID().equals(songPID) && s.getSample().equals(sample)){
				result = s;
				
			}
		}
		
	
			//result = new Associate(result1.getProduct_id(), result2.getName());
	
		return result;
	}

	public synchronized void addContainsas(containsas obj) throws RecordDuplicateException{
		if (findContainsas(obj.getAlbumID(), obj.getSongID(), obj.getSample()) != null){
			throw new RecordDuplicateException("Relation Containsas with Album ID: " + obj.getAlbumID() + " and" + " Song ID: " + obj.getSongID() + " is already in the db.");
		}
		else {
			containsasList.add(obj);
			
		}
	}

}
